import request from "@/utils/request.js";

//用户注册接口
export const reqRegister = ({username,password,repassword}) => {
    return request({
        url:"/api/reg",
        method:"post",
        data:{username,password,repassword}
    })
}

//用户登录接口
export const  reqLogin = ({username,password}) => {
    return request({
        url:"/api/login",
        method:"post",
        data:{username,password}
    })
}

//获取用户基本资料
export const reqUserInfo = (token) => {
    return request({
        url:"/my/userinfo",
        method:"get",
        headers:{
            Authorization:token
        }
    })
}

//获取当前用户的侧边栏导航数据
export const reqUserMenus = () => {
    return request({
        url:"/my/menus",
        method:"get",
        headers:{
            Authorization:localStorage.getItem("user_token")
        }
    })
}

//更新用户基本资料
export function reqUpdateUserInfo({id,username,nickname,email,user_pic}){
    return request({
        url:"/my/userinfo",
        method:"put",
        data:{id,username,nickname,email,user_pic}
    })
}

//更新用户头像
export const reqUpdateAvatar = (base64) => {
    return request({
        url:"/my/update/avatar",
        method:"patch",
        data:{avatar:base64}
    })
}

//更新用户密码
export const reqUpdateUserPwd = ({old_pwd,new_pwd,re_pwd}) => {
    return request({
        url:"/my/updatepwd",
        method:"patch",
        data:{old_pwd,new_pwd,re_pwd}
    })
}